test_progs = [
	'core_auth',
	'core_getclient',
	'core_getstats',
	'core_getversion',
	'core_setmaster',
	'core_setmaster_vs_auth',
	'debugfs_test',
	'dmabuf',
	'dmabuf_sync_file',
	'device_reset',
	'drm_buddy',
	'drm_mm',
	'drm_read',
	'fbdev',
	'feature_discovery',
	'kms_3d',
	'kms_addfb_basic',
	'kms_async_flips',
	'kms_atomic',
	'kms_atomic_interruptible',
	'kms_atomic_transition',
	'kms_bw',
	'kms_concurrent',
	'kms_content_protection',
	'kms_cursor_crc',
	'kms_cursor_edge_walk',
	'kms_cursor_legacy',
	'kms_dither',
	'kms_display_modes',
	'kms_dp_aux_dev',
	'kms_dp_tiled_display',
	'kms_flip',
	'kms_flip_event_leak',
	'kms_force_connector_basic',
	'kms_getfb',
	'kms_hdmi_inject',
	'kms_hdr',
	'kms_invalid_mode',
	'kms_lease',
	'kms_multipipe_modeset',
	'kms_panel_fitting',
	'kms_pipe_crc_basic',
	'kms_plane',
	'kms_plane_alpha_blend',
	'kms_plane_cursor',
	'kms_plane_lowres',
	'kms_plane_multiple',
	'kms_plane_scaling',
	'kms_prime',
	'kms_prop_blob',
	'kms_properties',
	'kms_rmfb',
	'kms_rotation_crc',
	'kms_scaling_modes',
	'kms_selftest',
	'kms_sequence',
	'kms_setmode',
	'kms_sysfs_edid_timing',
	'kms_tv_load_detect',
	'kms_universal_plane',
	'kms_vblank',
	'kms_vrr',
	'kms_writeback',
	'meta_test',
	'panfrost_get_param',
	'panfrost_gem_new',
	'panfrost_prime',
	'panfrost_submit',
	'prime_busy',
	'prime_mmap',
	'prime_mmap_coherency',
	'prime_mmap_kms',
	'prime_self_import',
	'prime_udl',
	'prime_vgem',
	'syncobj_basic',
	'syncobj_wait',
	'syncobj_timeline',
	'template',
	'tools_test',
	'vgem_basic',
	'vgem_slow',
]

i915_progs = [
	'api_intel_allocator',
	'api_intel_bb',
	'gen3_mixed_blits',
	'gen3_render_linear_blits',
	'gen3_render_mixed_blits',
	'gen3_render_tiledx_blits',
	'gen3_render_tiledy_blits',
	'gem_bad_reloc',
	'gem_basic',
	'gem_blits',
	'gem_busy',
	'gem_caching',
	'gem_ccs',
	'gem_close',
	'gem_close_race',
	'gem_concurrent_blit',
	'gem_cs_tlb',
	'gem_ctx_bad_destroy',
	'gem_ctx_create',
	'gem_ctx_engines',
	'gem_ctx_exec',
	'gem_ctx_isolation',
	'gem_ctx_param',
	'gem_ctx_persistence',
	'gem_ctx_shared',
	'gem_ctx_switch',
	'gem_evict_alignment',
	'gem_evict_everything',
	'gem_exec_alignment',
	'gem_exec_async',
	'gem_exec_await',
	'gem_exec_basic',
	'gem_exec_big',
	'gem_exec_capture',
	'gem_exec_create',
	'gem_exec_endless',
	'gem_exec_fair',
	'gem_exec_fence',
	'gem_exec_flush',
	'gem_exec_gttfill',
	'gem_exec_latency',
	'gem_exec_lut_handle',
	'gem_exec_nop',
	'gem_exec_parallel',
	'gem_exec_params',
	'gem_exercise_blt',
	'gen7_exec_parse',
	'gen9_exec_parse',
	'gem_exec_reloc',
	'gem_exec_schedule',
	'gem_exec_store',
	'gem_exec_suspend',
	'gem_exec_whisper',
	'gem_fd_exhaustion',
	'gem_fence_thrash',
	'gem_fence_upload',
	'gem_fenced_exec_thrash',
	'gem_flink_basic',
	'gem_flink_race',
	'gem_gpgpu_fill',
	'gem_gtt_cpu_tlb',
	'gem_gtt_hog',
	'gem_gtt_speed',
	'gem_huc_copy',
	'gem_linear_blits',
	'gem_lmem_evict',
	'gem_lmem_swapping',
	'gem_lut_handle',
	'gem_madvise',
	'gem_media_fill',
	'gem_media_vme',
	'gem_mmap',
	'gem_mmap_gtt',
	'gem_mmap_wc',
	'gem_partial_pwrite_pread',
	'gem_pipe_control_store_loop',
	'gem_ppgtt',
	'gem_pread',
	'gem_pread_after_blit',
	'gem_pwrite',
	'gem_pwrite_snooped',
	'gem_pxp',
	'gem_read_read_speed',
	'gem_readwrite',
	'gem_reg_read',
	'gem_render_copy',
	'gem_render_copy_redux',
	'gem_render_linear_blits',
	'gem_render_tiled_blits',
	'gem_request_retire',
	'gem_reset_stats',
	'gem_ringfill',
	'gem_set_tiling_vs_blt',
	'gem_set_tiling_vs_gtt',
	'gem_set_tiling_vs_pwrite',
	'gem_shrink',
	'gem_softpin',
	'gem_spin_batch',
	'gem_streaming_writes',
	'gem_sync',
	'gem_tiled_blits',
	'gem_tiled_fence_blits',
	'gem_tiled_partial_pwrite_pread',
	'gem_tiled_pread_basic',
	'gem_tiled_pread_pwrite',
	'gem_tiled_swapping',
	'gem_tiled_wb',
	'gem_tiled_wc',
	'gem_tiling_max_stride',
	'gem_unfence_active_buffers',
	'gem_unref_active_buffers',
	'gem_userptr_blits',
	'gem_vm_create',
	'gem_wait',
	'gem_watchdog',
	'gem_workarounds',
	'i915_fb_tiling',
	'i915_getparams_basic',
	'i915_hangman',
	'i915_hwmon',
	'i915_module_load',
	'i915_pciid',
	'i915_pipe_stress',
	'i915_pm_backlight',
	'i915_pm_lpsp',
	'i915_pm_rpm',
	'i915_pm_dc',
	'i915_pm_rps',
	'i915_pm_sseu',
	'i915_power',
	'i915_query',
	'i915_selftest',
	'i915_suspend',
	'kms_big_fb',
	'kms_big_joiner' ,
	'kms_busy',
	'kms_ccs',
	'kms_cdclk',
	'kms_draw_crc',
	'kms_fbcon_fbt',
	'kms_fence_pin_leak',
	'kms_flip_scaled_crc',
	'kms_flip_tiling',
	'kms_frontbuffer_tracking',
	'kms_legacy_colorkey',
	'kms_mmap_write_crc',
	'kms_pipe_b_c_ivb',
	'kms_psr',
	'kms_psr2_su',
	'kms_psr_stress_test',
	'kms_pwrite_crc',
	'sysfs_defaults',
	'sysfs_heartbeat_interval',
	'sysfs_preempt_timeout',
	'sysfs_timeslice_duration',
]

xe_progs = [
	'xe_compute',
	'xe_dma_buf_sync',
	'xe_debugfs',
	'xe_evict',
	'xe_exec_balancer',
	'xe_exec_basic',
	'xe_exec_compute_mode',
	'xe_exec_fault_mode',
	'xe_exec_reset',
	'xe_exec_threads',
	'xe_guc_pc',
	'xe_huc_copy',
	'xe_mmap',
	'xe_mmio',
	'xe_noexec_ping_pong',
	'xe_pm',
	'xe_prime_self_import',
	'xe_query',
	'xe_vm',
	'xe_waitfence',
]

msm_progs = [
	'msm_mapping',
	'msm_recovery',
	'msm_shrink',
	'msm_submit'
]

chamelium_progs = [
	'kms_chamelium_audio',
	'kms_chamelium_edid',
	'kms_chamelium_frames',
	'kms_chamelium_hpd',
]

test_deps = [ igt_deps ]

if libdrm_nouveau.found()
	test_progs += [
		'prime_nv_api',
		'prime_nv_pcopy',
		'prime_nv_test',
		'nouveau_crc',
	]
	test_deps += libdrm_nouveau
endif

test_executables = []
test_list = []

foreach prog : test_progs
	test_executables += executable(prog, prog + '.c',
		   dependencies : test_deps,
		   install_dir : libexecdir,
		   install_rpath : libexecdir_rpathdir,
		   install : true)
	test_list += prog
endforeach

foreach prog : i915_progs
	test_executables += executable(prog,
		   join_paths('i915', prog + '.c'),
		   dependencies : test_deps,
		   install_dir : libexecdir,
		   install_rpath : libexecdir_rpathdir,
		   install : true)
	test_list += prog
endforeach

foreach prog : xe_progs
	test_executables += executable(prog,
		   join_paths('xe', prog + '.c'),
		   dependencies : test_deps,
		   install_dir : libexecdir,
		   install_rpath : libexecdir_rpathdir,
		   install : true)
	test_list += prog
endforeach

foreach prog : msm_progs
	test_executables += executable(prog, join_paths('msm', prog + '.c'),
				       dependencies : test_deps,
				       install_dir : libexecdir,
				       install_rpath : libexecdir_rpathdir,
				       install : true)
	test_list += prog
endforeach

if chamelium.found()
	foreach prog : chamelium_progs
		test_executables += executable(prog,
				 [join_paths('chamelium', prog + '.c'),
					join_paths('chamelium', 'kms_chamelium_helper.c')],
				 dependencies : test_deps,
				 install_dir : libexecdir,
				 install_rpath : libexecdir_rpathdir,
				 install : true)
		test_list += prog
	endforeach
	test_deps += chamelium
endif

test_executables += executable('drm_fdinfo',
	   join_paths('i915', 'drm_fdinfo.c'),
	   dependencies : test_deps + [ lib_igt_drm_fdinfo ],
	   install_dir : libexecdir,
	   install_rpath : libexecdir_rpathdir,
	   install : true)
test_list += 'drm_fdinfo'

test_executables += executable('dumb_buffer', 'dumb_buffer.c',
	   dependencies : test_deps + [ libatomic ],
	   install_dir : libexecdir,
	   install_rpath : libexecdir_rpathdir,
	   install : true)
test_list += 'dumb_buffer'

test_executables += executable('gem_create',
	   join_paths('i915', 'gem_create.c'),
	   dependencies : test_deps + [ libatomic ],
	   install_dir : libexecdir,
	   install_rpath : libexecdir_rpathdir,
	   install : true)
test_list += 'gem_create'

test_executables += executable('gem_ctx_freq',
	   join_paths('i915', 'gem_ctx_freq.c'),
	   dependencies : test_deps + [ lib_igt_perf ],
	   install_dir : libexecdir,
	   install_rpath : libexecdir_rpathdir,
	   install : true)
test_list += 'gem_ctx_freq'

test_executables += executable('gem_ctx_sseu',
	   join_paths('i915', 'gem_ctx_sseu.c'),
	   dependencies : test_deps + [ lib_igt_perf ],
	   install_dir : libexecdir,
	   install_rpath : libexecdir_rpathdir,
	   install : true)
test_list += 'gem_ctx_sseu'

test_executables += executable('gem_eio',
	   join_paths('i915', 'gem_eio.c'),
	   dependencies : test_deps + [ realtime ],
	   install_dir : libexecdir,
	   install_rpath : libexecdir_rpathdir,
	   install : true)
test_list += 'gem_eio'

test_executables += executable('gem_exec_balancer', 'i915/gem_exec_balancer.c',
	   dependencies : test_deps + [ lib_igt_perf ],
	   install_dir : libexecdir,
	   install_rpath : libexecdir_rpathdir,
	   install : true)
test_list += 'gem_exec_balancer'

test_executables += executable('gem_mmap_offset',
	   join_paths('i915', 'gem_mmap_offset.c'),
	   dependencies : test_deps + [ libatomic ],
	   install_dir : libexecdir,
	   install_rpath : libexecdir_rpathdir,
	   install : true)
test_list += 'gem_mmap_offset'

test_executables += executable('i915_pm_freq_mult',
	   join_paths('i915', 'i915_pm_freq_mult.c'),
	   dependencies : test_deps + [ lib_igt_perf ],
	   install_dir : libexecdir,
	   install_rpath : libexecdir_rpathdir,
	   install : true)
test_list += 'i915_pm_freq_mult'

test_executables += executable('i915_pm_rc6_residency',
	   join_paths('i915', 'i915_pm_rc6_residency.c'),
	   dependencies : test_deps + [ lib_igt_perf ],
	   install_dir : libexecdir,
	   install_rpath : libexecdir_rpathdir,
	   install : true)
test_list += 'i915_pm_rc6_residency'

test_executables += executable('gem_barrier_race',
	   join_paths('i915', 'gem_barrier_race.c'),
	   dependencies : test_deps + [ lib_igt_i915_perf ],
	   install_dir : libexecdir,
	   install_rpath : libexecdir_rpathdir,
	   install : true)
test_list += 'gem_barrier_race'

test_executables += executable('perf_pmu',
	   join_paths('i915', 'perf_pmu.c'),
	   dependencies : test_deps + [ lib_igt_perf ],
	   install_dir : libexecdir,
	   install_rpath : libexecdir_rpathdir,
	   install : true)
test_list += 'perf_pmu'

test_executables += executable('perf',
	   join_paths('i915', 'perf.c'),
	   dependencies : test_deps + [ lib_igt_i915_perf ],
	   install_dir : libexecdir,
	   install_rpath : libexecdir_rpathdir,
	   install : true)
test_list += 'perf'

test_executables += executable('core_hotunplug', 'core_hotunplug.c',
	   dependencies : test_deps + [ lib_igt_i915_perf ],
	   install_dir : libexecdir,
	   install_rpath : libexecdir_rpathdir,
	   install : true)
test_list += 'core_hotunplug'

executable('testdisplay', ['testdisplay.c', 'testdisplay_hotplug.c'],
	   dependencies : test_deps,
	   install_dir : libexecdir,
	   install_rpath : libexecdir_rpathdir,
	   install : true)
test_list += 'testdisplay'

test_executables += executable('kms_color',
	   [ 'kms_color.c', 'kms_color_helper.c' ],
	   dependencies : test_deps,
	   install_dir : libexecdir,
	   install_rpath : libexecdir_rpathdir,
	   install : true)
test_list += 'kms_color'

test_executables += executable('kms_dsc',
	   [ join_paths('i915', 'kms_dsc.c'), join_paths ('i915', 'kms_dsc_helper.c')],
	   dependencies : test_deps,
	   install_dir : libexecdir,
	   install_rpath : libexecdir_rpathdir,
	   install : true)
test_list += 'kms_dsc'

test_executables += executable('kms_psr2_sf',
	   [ join_paths('i915', 'kms_psr2_sf.c'), join_paths ('i915', 'kms_dsc_helper.c')],
	   dependencies : test_deps,
	   install_dir : libexecdir,
	   install_rpath : libexecdir_rpathdir,
	   install : true)
test_list += 'kms_psr2_sf'

if chamelium.found()
       test_executables += executable('kms_chamelium_color',
                             [ 'chamelium/kms_chamelium_color.c', 'kms_color_helper.c' ],
                             dependencies : test_deps + [ chamelium ],
                             install_dir : libexecdir,
                             install_rpath : libexecdir_rpathdir,
                             install : true)
       test_list += 'kms_chamelium_color'
endif

test_executables += executable('sw_sync', 'sw_sync.c',
	   dependencies : test_deps + [ libatomic ],
	   install_dir : libexecdir,
	   install_rpath : libexecdir_rpathdir,
	   install : true)
test_list += 'sw_sync'

subdir('amdgpu')
subdir('xe')

subdir('v3d')

subdir('vc4')

gen_testlist = find_program('generate_testlist.sh')
test_list_target = custom_target('testlist',
	      output : 'test-list.txt',
	      command : [ gen_testlist, '@OUTPUT@', test_list ],
	      install : true,
	      install_dir : libexecdir)

test_executables += executable('gem_concurrent_all', 'i915/gem_concurrent_all.c',
	   dependencies : test_deps + [ libatomic ],
	   install_dir : libexecdir,
	   install_rpath : libexecdir_rpathdir,
	   install : true)
test_list += 'gem_concurrent_all'

test_list_full_target = custom_target('testlist-full',
	      output : 'test-list-full.txt',
	      command : [ gen_testlist, '@OUTPUT@', test_list ],
	      install : true,
	      install_dir : libexecdir)

test_script = find_program('igt_command_line.sh')
foreach prog : test_list
	test('testcase check ' + prog, test_script, args : prog)
endforeach

executable('gem_stress', 'i915/gem_stress.c',
	   install : true,
	   install_dir : libexecdir,
	   install_rpath : libexecdir_rpathdir,
	   dependencies : igt_deps)

image_files = [
  '1080p-left.png',
  '1080p-right.png',
  'pass.png',
]
install_data(sources : image_files, install_dir : datadir)

subdir('intel-ci')
